Crash Purebasic, application freeze while using curl?

Just starting out? Need help? Post your questions and find answers here.
stmdbe2019
User
User
Posts: 89
Joined: Mon Aug 31, 2009 2:11 pm

Crash Purebasic, application freeze while using curl?

Post by stmdbe2019 »

Application crash while using curl method to upload picture as below with timer set to 300? How to avoid crash or on crash resume next and again continue but do not die?

Code: Select all


Procedure webServiceUpload(pictureData.s) 
  curl = curl_easy_init()
  url.s = str2curl(myURL$)
  agent.s = str2curl("pbcurl/1.0")
  cookie.s = str2curl("agent=" + myAgent$ + ";")
  post.s = str2curl("pic=" + "Data:image/png;base64," + pictureData)
  header.s = str2curl("Cache-Control: no-cache")
  If curl
    curl_easy_setopt(curl,#CURLOPT_URL,@url)
    curl_easy_setopt(curl,#CURLOPT_IPRESOLVE,#CURL_IPRESOLVE_V4)
    curl_easy_setopt(curl,#CURLOPT_COOKIE,@cookie)
    curl_easy_setopt(curl,#CURLOPT_POSTFIELDS,@post)
    curl_easy_setopt(curl,#CURLOPT_USERAGENT,@agent)
    curl_easy_setopt(curl,#CURLOPT_TIMEOUT,30)
    curl_easy_setopt(curl,#CURLOPT_FOLLOWLOCATION,1)
    *header = curl_slist_append(0,header)
    curl_easy_setopt(curl,#CURLOPT_HTTPHEADER,*header)
    curl_easy_setopt(curl,#CURLOPT_WRITEFUNCTION,@curlWriteData())
    res = curl_easy_perform(curl)
    resData.s = curlGetData()
    curl_easy_getinfo(curl,#CURLINFO_RESPONSE_CODE,@resHTTP)

    curl_easy_cleanup(curl)
  Else
    Debug "can't init curl!"
  EndIf
EndProcedure
;AddWindowTimer(MainWindow, 123, 300)
webService(Base64_Image2.s)

Image
-----
Registered PureBasic Coder.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: Crash Purebasic, application freeze while using curl?

Post by srod »

All I can see from a quick glance is that you are using PeekS() on an Ascii string, but whilst running in Unicode mode! That could cause problems.

Try PeekS(*curlstring, -1, #PB_Ascii)
I may look like a mule, but I'm not a complete ass.
Post Reply